<?php

interface IExceptionHandler {

    public function ExceptionHandler(Exception $e);
}

/*
 * Controller exceptions
 */

//class JsonException extends Exception {
//
//    public function __construct($message) {
//        parent::__construct($message);
//    }
//
//    public function jsonize() {
//        return [
//            'exception' => parent::getMessage(),
//        ];
//    }
//
//}

class ControllerException extends /* Json */Exception {

    public function __construct($message) {
        parent::__construct($message);
    }

}

class ViewException extends Exception {

    public function __construct($message, $code = 0) {
        parent::__construct($message, $code);
    }

}

class AuthenticationException extends ControllerException {

    public function __construct($message) {
        parent::__construct($message);
    }

}

/*
 * Argument exceptions
 */

class ArgumentException extends Exception {

    private $argument;

    public function __construct($argument, $message = NULL, $code = NULL, $previous = NULL) {
        $this->argument = $argument;
        parent::__construct($message, $code, $previous);
    }

    public function getName() {
        return $this->argument;
    }

}

class ArgumentNullException extends ArgumentException {
    
}

class ArgumentOutOfRangeException extends ArgumentFormatException {
    
}

class ArgumentFormatException extends ArgumentException {
    
}

/*
 * Data exceptions
 */

class DataException extends Exception {

    public function __construct($message = NULL, $code = NULL, $previous = NULL) {
        parent::__construct($message, $code, $previous);
    }

}

class HeaderDataException extends DataException {

    public function __construct($message = NULL, $code = NULL, $previous = NULL) {
        parent::__construct($message, $code, $previous);
    }

}

class SqlCommandException extends DataException {
    
}

class RowDataException extends DataException {

    private $row;

    public function __construct($row, $message = NULL, $code = NULL, $previous = NULL) {
        $this->row = $row;
        parent::__construct($message, $code, $previous);
    }

    public function getRow() {
        return $this->row;
    }

}

class RowLengthException extends RowDataException {

    public function __construct($row, $message = NULL, $code = NULL, $previous = NULL) {
        parent::__construct($row, $message, $code, $previous);
    }

}
